import { combineReducers, configureStore } from "@reduxjs/toolkit";
import dataSlice from './reducers/dataSlice';
import infoSlice from './reducers/infoSilce';

import { persistReducer, persistStore } from 'redux-persist'
import storage from 'redux-persist/es/storage'

// 缓存数据配置
const persistConfig:any = {
    key: 'root',
    storage,
    blacklist: [] // 写在这块的数据不会存在storage 黑名单 
}

const reducers = combineReducers({
    MyData:dataSlice,
    MyInfo:infoSlice,
})

// 持久化reducers 转换为持久化数据
const persistedReducer = persistReducer(persistConfig,reducers)

export const store = configureStore({
    reducer:persistedReducer,

    middleware: (getDefaultMiddleware) =>
    getDefaultMiddleware({
        serializableCheck: false,
    })
})

// 数据持久化存储
export const persistor = persistStore(store)